package com.xin.springboot.controller;


import com.xin.springboot.bean.User;
import com.xin.springboot.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController //=@Controller + @ResponseBody
//@RequestMapping(value = "/api/user")

public class UserController
{
//    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(UserController.class);
    @Autowired
    private UserServices userServices;

    @PostMapping(value = "/api/user/register")
    @CrossOrigin(origins = "*",maxAge = 3600)
    @ResponseBody
    public User register(@RequestBody User user){
        System.out.println(user.getName()+","+user.getAge()+","+user.getPwd());
        return userServices.register(user);
    }

    @PostMapping(value = "/api/user/login")
    @CrossOrigin(origins = "*",maxAge = 3600)
    @ResponseBody
    public User login(@RequestBody User user){
        System.out.println(user.getName()+","+user.getPwd());
        return userServices.login(user);
    }
}

